/*            Copyright(c) 2006-2008 Dave Sexton           *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;

namespace DaveSexton.DocProject
{
	internal static class NativeMethods
	{
		#region Imports
		#region Public
		[DllImport("user32.dll", CharSet = CharSet.Unicode)]
		public static extern IntPtr FindWindowEx(IntPtr parent, IntPtr childAfter, string className, string windowName);
		#endregion

		#region Private
		[DllImport("user32.dll")]
		[return: MarshalAs(UnmanagedType.Bool)]
		private static extern bool GetWindowRect(IntPtr window, out Rect bounds);
		#endregion
		#endregion

		#region Wrappers
		public static Rectangle GetWindowRectangle(IntPtr window)
		{
			Rect rect;
			if (!GetWindowRect(window, out rect))
				return Rectangle.Empty;
			else
				return Rectangle.FromLTRB(rect.left, rect.top, rect.right, rect.bottom);
		}
		#endregion

		#region Nested
		[StructLayout(LayoutKind.Sequential)]
		private struct Rect
		{
			public int left, top, right, bottom;
		}
		#endregion
	}
}
